using HDS.Common.Helper;
using Newtonsoft.Json;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Text;

namespace HDS.Model.Entity.Master
{
    /// <summary>
    /// 房型 
    /// </summary>
    [SugarTable("hotel_room")]
    public class HotelRoom
    {

        /// <summary>
        /// 房型id
        /// </summary>
        [SugarColumn(IsPrimaryKey = true, IsIdentity = true, ColumnName = "room_id")]
        public int RoomId { get; set; }

        /// <summary>
        /// 酒店id
        /// </summary>
        [SugarColumn(ColumnName = "hotel_id")]
        public int HotelId { get; set; }

        /// <summary>
        /// 英文房型名称
        /// </summary>
        [SugarColumn(ColumnName = "room_name_en")]
        public string RoomNameEn { get; set; }

        /// <summary>
        /// 中文房型名称
        /// </summary>
        [SugarColumn(ColumnName = "room_name_cn")]
        public string RoomNameCn { get; set; }

        /// <summary>
        /// 房型面积
        /// </summary>
        [SugarColumn(ColumnName = "room_area")]
        public string RoomArea { get; set; }

        /// <summary>
        /// 最大入住人数
        /// </summary>
        [SugarColumn(ColumnName = "max_occupancy")]
        public int MaxOccupancy { get; set; } = 2;

        /// <summary>
        /// 床型数组json [[{"type":"single","num":2,"width":0}]]
        /// </summary>
        [SugarColumn(ColumnName = "room_beds", IsJson = true)]
        public List<List<RoomBedType>> RoomBeds { get; set; }

        /// <summary>
        /// 房型状态 1:有效,0:删除
        /// </summary>
        [SugarColumn(ColumnName = "room_status")]
        public bool RoomStatus { get; set; }

        /// <summary>
        /// 房型信息md5
        /// </summary>
        [SugarColumn(ColumnName = "room_md5")]
        public string RoomMd5 { get; set; }

        /// <summary>
        /// 第三方房型id
        /// </summary>
        [SugarColumn(ColumnName = "third_party_id")]
        public string ThirdPartyId { get; set; }

        /// <summary>
        /// 更新人id
        /// </summary>
        [SugarColumn(ColumnName = "updated_by")]
        public int UpdatedBy { get; set; }

        /// <summary>
        /// 更新人姓名
        /// </summary>
        [SugarColumn(ColumnName = "updated_by_name")]
        public string UpdatedByName { get; set; }

        /// <summary>
        /// 更新时间
        /// </summary>
        [SugarColumn(ColumnName = "updated_time")]
        public DateTime UpdatedTime { get; set; }


        public static string CreateRoomMd5(HotelRoom entity)
        {
            return (entity.RoomNameEn + entity.RoomNameCn + entity.RoomArea + entity.MaxOccupancy + JsonConvert.SerializeObject(entity.RoomBeds)).CreateMD5();
        }
    }
}
